// Minimal test client using WebSocket
const url = `ws://localhost:${process.env.PORT || 3000}`;
const ws = new WebSocket(url);

ws.onopen = () => {
  console.log('client: connected');
  const msg = JSON.stringify({
    event: 'chat:message',
    data: { roomId: 'room1', userId: 'user1', message: 'Hello from test' },
    timestamp: Date.now()
  });
  ws.send(msg);
};

ws.onmessage = (ev) => {
  console.log('client: message', ev.data);
  // close after first message for demo
  // ws.close();
};

ws.onclose = () => {
  console.log('client: closed');
  process.exit(0);
};

ws.onerror = (err) => {
  console.error('client: error', err);
  process.exit(1);
};
